<%@ page import="top.lbqaq.pojo.ProductIn" %>
<%@ page import="top.lbqaq.util.pageBean" %>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%--
  Created by IntelliJ IDEA.
  User: the world
  Date: 2021/12/27
  Time: 11:07
  To change this template use File | Settings | File Templates.
--%>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<%@include file="/jsp/common/head.jsp" %>

<form action="${pageContext.request.contextPath}/productIn">
    <table class="table table-hover">
        <thead>

        <tr>
            <th scope="col">id</th>
            <th scope="col">类别1</th>
            <th scope="col">类别2</th>
            <th scope="col">产品名称</th>
            <th scope="col">单位</th>
            <th scope="col">数量</th>
            <th scope="col">日期</th>
            <th scope="col">备注</th>
            <th scope="col">供货商</th>
            <th scope="col">  <div class="col-md-2">
                <input type="submit" class="btn btn-primary" name="insert" value="新入库"/>
                <%--                    <a href="${pageContext.request.contextPath}/jsp/px.jsp">点此跳转</a>--%>
            </div> </th>


            <div class="col-md-2">
                <input type="submit" class="btn btn-primary" name="up" value="刷新"/>
                <%--                    <a href="${pageContext.request.contextPath}/jsp/px.jsp">点此跳转</a>--%>
            </div>
            </th>
        </tr>

        </thead>

        <tbody>

            <% if(request.getAttribute("productList")!=null){
        pageBean<ProductIn> products = (pageBean<ProductIn>) request.getAttribute("productList");
        for (int i = 0; i < products.getList().size(); i++) {
        %>
        <tr>
            <th>
                <%= products.getList().get(i).getId()%>
            </th>
            <th>
                <%= products.getList().get(i).getProductCategory1()%>
            </th>
            <th>
                <%= products.getList().get(i).getProductCategory2()%>
            </th>
            <th>
                <%= products.getList().get(i).getProductName()%>
            </th>
            <th>
                <%= products.getList().get(i).getProductUnit()%>
            </th>
            <th>
                <%= products.getList().get(i).getProductNumber()%>
            </th>
            <th>
                <%= products.getList().get(i).getProductInDate()%>
            </th>
            <th>
                <%= products.getList().get(i).getProductRemark()%>
            </th>
            <th>
                <%= products.getList().get(i).getProductSupplier()%>
            </th>

        </tr>
        </tbody>
            <%
        }
    %>
            <%
        }
    %>
                <% if(request.getAttribute("product")!=null){
       ProductIn product = (ProductIn) request.getAttribute("product");
    %>
            <tr>
                <th>
                    <%= product.getId()%>
                </th>
                <th>
                    <%= product.getProductCategory1()%>
                </th>
                <th>
                    <%= product.getProductCategory2()%>
                </th>
                <th>
                    <%= product.getProductName()%>
                </th>
                <th>
                    <%= product.getProductUnit()%>
                </th>
                <th>
                    <%= product.getProductNumber()%>
                </th>
                <th>
                    <%=product.getProductInDate()%>
                </th>
                <th>
                    <%= product.getProductRemark()%>
                </th>
                <th>
                    <%= product.getProductSupplier()%>
                </th>
                <th>
                    <a style="margin-top:5px;" class="btn btn-primary btn-sm" href="${pageContext.request.contextPath}/productIn?name1=insert&Category1=<%= product.getProductCategory1()%>&Category2=<%= product.getProductCategory2()%>&name=<%= product.getProductName()%>&unit=<%= product.getProductUnit()%>&number=<%= product.getProductNumber()%>&date=<%=product.getProductInDate()%>&remark=<%= product.getProductRemark()%>&supplier= <%= product.getProductSupplier()%>">确认入库</a>

                </th>
            </tr>


                <%
        }
    %>
</form>

</table>

<c:if test="${productList.pageNum !=null}">
<a href="${pageContext.request.contextPath}/productIn?pageNum=1&up=刷新">首页</a>
<%--如果当前页为第一页时，就没有上一页这个超链接显示 --%>
<c:if test="${productList.pageNum ==1}">
    <c:forEach begin="${productList.start}" end="${productList.end}" step="1" var="i">
        <c:if test="${productList.pageNum == i}">
            ${i}
        </c:if>
        <c:if test="${productList.pageNum != i}">
            <a href="${pageContext.request.contextPath}/productIn?pageNum=${i}&up=刷新">${i}</a>
        </c:if>
    </c:forEach>
    <c:if test="${productList.totalPage !=1}">
        <a href="${pageContext.request.contextPath}/productIn?pageNum=${productList.pageNum+1}&up=刷新">下一页</a>
    </c:if>
</c:if>
<%--如果当前页不是第一页也不是最后一页，则有上一页和下一页这个超链接显示 --%>
<c:if test="${productList.pageNum > 1 && productList.pageNum < productList.totalPage}">
    <a href="${pageContext.request.contextPath}/productIn?pageNum=${productList.pageNum-1}&up=刷新">上一页</a>
    <c:forEach begin="${productList.start}" end="${productList.end}" step="1" var="i">
        <c:if test="${productList.pageNum == i}">
            ${i}
        </c:if>
        <c:if test="${productList.pageNum != i}">
            <a href="${pageContext.request.contextPath}/productIn?pageNum=${i}&up=刷新">${i}</a>
        </c:if>
    </c:forEach>
    <a href="${pageContext.request.contextPath}/productIn?pageNum=${productList.pageNum+1}&up=刷新">下一页</a>
</c:if>

<%--&lt;%&ndash; 如果当前页是最后一页，则只有上一页这个超链接显示，下一页没有 &ndash;%&gt;如果是第一页不需要--%>
<c:if test="${productList.pageNum == productList.totalPage}">
    <c:if test="${productList.pageNum !=1}">
        <a href="${pageContext.request.contextPath}/productIn?pageNum=${productList.pageNum-1}&up=刷新">上一页</a>
        <c:forEach begin="${productList.start}" end="${productList.end}" step="1" var="i">
            <c:if test="${productList.pageNum == i}">
                ${i}
            </c:if>
            <c:if test="${productList.pageNum != i}">
                <a href="${pageContext.request.contextPath}/productIn?pageNum=${i}&up=刷新">${i}</a>
            </c:if>
        </c:forEach>
    </c:if>
</c:if>
<%--尾页 --%>
<a href="${pageContext.request.contextPath}/productIn?pageNum=${productList.totalPage}&up=刷新">尾页</a>
</c:if>

<%@include file="/jsp/common/footer.jsp"%>